Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The encode_type function was incorrectly propagating the RiverError base class to all nested types when generating error schemas. This meant that if an error type had nested object properties (e.g., a field containing user details or metadata), those nested objects would also inherit from RiverError instead of BaseModel. This is incorrect because only the top-level error types should inherit from RiverError - nested properties are just data structures, not errors themselves.
What changed
Modified the encode_type function to pass "BaseModel" instead of the current base_model value when recursively processing object properties (line 538). This is done conditionally only when the current base_model is "RiverError". The fix ensures that:
Top-level error types and union members of error types continue to inherit from RiverError
Nested properties within those error types inherit from BaseModel
All other base model types ("TypedDict", "BaseModel") maintain their existing behavior unchanged